package kr.co.project1.service;

import kr.co.project1.base.PageDto;
import kr.co.project1.dao.BoardDao;
import kr.co.project1.vo.BoardVO;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class BoardService {
	
	private static final Logger logger = LoggerFactory.getLogger(BoardService.class);
	
	@Autowired
	private BoardDao boardDao;

	public PageDto<BoardVO> list(BoardVO boardVO) {
		logger.debug("======BoardService.list======");
		return boardDao.list(boardVO);
	}

	public int insertItem(BoardVO boardVO) {
		logger.debug("======BoardService.insertItem======");
		return boardDao.insertItem(boardVO);
	}

	public BoardVO getItem(BoardVO boardVO) {
		logger.debug("======BoardService.getItem======");
		return boardDao.getItem(boardVO);
	}

	public int modifyItem(BoardVO boardVO) {
		logger.debug("======BoardService.modifyItem======");
		return boardDao.modifyItem(boardVO);		
	}

	public int deletes(BoardVO boardVO) {
		logger.debug("======BoardService.deletes======");
		int result = 0;
		
		for (int i = 0; i < boardVO.getSeqArr().length; i++) {
			boardVO.setSeq(boardVO.getSeqArr()[i]);
			result = boardDao.deleteItem(boardVO);
		}		
		
		return result;
	}
	
	
	
}
